package com.daidai.tools

import android.content.Context
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.EditText

object ImTool {
    /**
     * 关闭输入法
     */
    fun closeKeyBoard(context: Context, editText: View) {
        //我加的
        val imm = context
                .getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        imm.hideSoftInputFromWindow(editText.windowToken, 0)
    }

    /**
     * 打开输入法
     */
    fun showSoftInputFromWindow(editText: EditText) {
        val inputManager = editText.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        inputManager.showSoftInput(editText, 0)
    }
}